﻿@namespace GraphRag.Net.Web.Pages.Graph
@page "/Chat"
@using GraphRag.Net.Domain.Interface

<GridContent>
    <Row Gutter="24">
        <Col Lg="7" Md="24">
            <Card Title="搜索图谱内容" Style="height:100%;" Bordered>
                <Spin Spinning=@loadding>
                    <div style="margin-bottom:16px;">
                        <Text Strong>选择索引</Text>
                        <Select TItem="string"
                                TItemValue="string"
                                ValueProperty="c=>c"
                                LabelProperty="c=>c"
                                DataSource="@_indexList"
                                @bind-Value="@_index"
                                Placeholder="选择索引"
                                Style="width:100%;"
                                OnSelectedItemChanged="OnSelectedItemChangedHandler">
                        </Select>
                    </div>
                    
                    <div style="margin-bottom:16px;">
                        <Text Strong>提问</Text>
                        <Input @bind-Value="_input" Placeholder="请输入您的问题" AllowClear />
                    </div>
                    
                    <div style="margin-bottom:16px;">
                        <Text Strong>回答结果</Text>
                        <TextArea @bind-Value="_output" MinRows="8" MaxRows="12" Placeholder="回答将显示在这里" Style="width:100%;" />
                    </div>
                    
                    <div style="display:flex; gap:8px; margin-top:16px;">
                        <Button Type="@ButtonType.Primary" OnClick="Search" Block>
                            <Icon Type="search" /> 节点搜索
                        </Button>
                        <Button Type="@ButtonType.Primary" OnClick="Search1" Block>
                            <Icon Type="cluster" /> 社区搜索
                        </Button>
                    </div>
                    
                    <Divider Style="margin:16px 0;" />
                    
                    <a href="/graph?index=@_index" target="_blank">
                        <Button Type="@ButtonType.Link" Block>
                            <Icon Type="eye" /> 查看完整图谱
                        </Button>
                    </a>
                </Spin>
            </Card>
        </Col>
        
        <Col Lg="7" Md="24">
            <Card Title="导入文本数据" Style="height:100%;" Bordered>
                <div style="margin-bottom:16px;">
                    <Text Strong>索引名称</Text>
                    <Input @bind-Value="_importIndex" Placeholder="索引名称，可以一个文件一个，也可以多个文件公用一个" AllowClear />
                </div>
                
                <div style="margin-bottom:16px;">
                    <Text Strong>文本内容</Text>
                    <TextArea @bind-Value="_importText" MinRows="10" MaxRows="14" Placeholder="输入文本进行导入" Style="width:100%;" />
                </div>
                
                <Button Type="@ButtonType.Primary" OnClick="InputText" Block>
                    <Icon Type="import" /> 导入文本
                </Button>
            </Card>
        </Col>

        <Col Lg="10" Md="24">
            <Card Title="导入TXT文件" Style="height:100%;" Bordered>
                <div style="margin-bottom:16px;">
                    <Text Strong>索引名称</Text>
                    <Input @bind-Value="_importIndex" Placeholder="索引名称，可以一个文件一个，也可以多个文件公用一个" AllowClear />
                </div>
                
                <div style="margin-top:24px; text-align:center;">
                    <Upload Action="@("api/Graph/ImportTxt?index="+_importIndex)"
                            Name="file"
                            Accept="text/plain"
                            BeforeUpload="BeforeUpload"
                            OnSingleCompleted="OnSingleCompleted"
                            Style="width:100%;"
                            Drag>
                        <p class="ant-upload-drag-icon" style="margin-bottom:8px;">
                            <Icon Type="inbox" Style="font-size:48px; color:#40a9ff;" />
                        </p>
                        <p class="ant-upload-text" style="font-size:16px;">点击或拖拽文件到此区域上传</p>
                        <p class="ant-upload-hint" style="color:#888;">
                            支持单个或批量上传，仅支持TXT文本文件
                        </p>
                    </Upload>
                </div>
                <a href="https://gw.antsk.cn" target="_blank">更多文件导入类型可以查看AntSK项目</a>
            </Card>
        </Col>
    </Row>
</GridContent>
@code {

  
}
